package com.example.service;

import com.example.pojo.Role;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class RoleServiceTest2 {
    private RoleService service;
    @Before
    public void start() {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContextTransaction.xml");
        service = context.getBean("roleService",RoleService.class);
    }

    @Test
    public void test() {
        Role one = service.findOne(1);
        System.out.println(one);
    }

    @Test(expected=Throwable.class)
    public void addOne() {
        Role role = new Role("tom", "普通用户", "0");
        System.out.println("以下将会回滚");
        service.addOne(role);
    }

}